home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctj8507.arc
/
SORT.COB
< prev
next >
Wrap
Text File
|
1986-09-14
|
4KB
|
129 lines
IDENTIFICATION DIVISION.
PROGRAM-ID. SORT.
* SORT BENCHMARK
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-PC.
OBJECT-COMPUTER. IBM-PC.
*
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT IN-FILE
* FOLLOWING 2 LINES FOR MICRSOFT
ASSIGN TO DISK
ORGANIZATION RELATIVE
* FOLLOWING 2 LINES FOR MICRO FOCUS & DRI
* ASSIGN TO "B:FILE1.SEQ"
* ORGANIZATION SEQUENTIAL
ACCESS SEQUENTIAL.
SELECT SORT-WORK
* FOLLOWING LINE FOR MICRSOFT
ASSIGN TO DISK.
* FOLLOWING LINE FOR MICRO FOCUS & DRI
* ASSIGN TO "A:SORT.WRK".
SELECT OUT-FILE
* FOLLOWING 2 LINES FOR MICRSOFT
ASSIGN TO DISK
ORGANIZATION RELATIVE
* FOLLOWING 2 LINES FOR MICRO FOCUS & DRI
* ASSIGN TO "B:FILE1.SEQ"
* ORGANIZATION SEQUENTIAL
ACCESS SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD IN-FILE LABEL RECORDS ARE STANDARD
* FOLLOWING LINE FOR MICROSOFT ONLY
VALUE OF FILE-ID IS "B:FILE1.SEQ"
DATA RECORD IS RECORD-1.
01 RECORD-1.
05 SEQ-REC-WORD PIC X(7).
05 SEQ-REC-NUM PIC 9(10).
05 SEQ-REC-TAIL PIC X(83).
FD OUT-FILE LABEL RECORDS ARE STANDARD
* FOLLOWING LINE FOR MICROSOFT ONLY
VALUE OF FILE-ID IS "B:FILE2.SEQ"
DATA RECORD IS RECORD-2.
01 RECORD-2 PIC X(100).
SD SORT-WORK
* FOLLOWING LINE FOR MICROSOFT ONLY
VALUE OF FILE-ID IS "B:SORT.WRK"
DATA RECORD IS SORT-RECORD.
01 SORT-RECORD.
05 SORT-REC-WORD PIC X(7).
05 SORT-REC-NUM PIC 9(10).
05 SORT-REC-TAIL PIC X(83).
WORKING-STORAGE SECTION.
77 REC-LIMIT PIC 9999.
77 HALF-WAY PIC 9999.
77 COUNTER-1 PIC 9999.
77 COUNTER-2 PIC 9999.
COPY TIMERDAT.
PROCEDURE DIVISION.
000-MAINLINE.
PERFORM 100-WRITE-FILE THRU 100-EXIT.
PERFORM 200-SORT-FILE THRU 200-EXIT.
STOP RUN.
100-WRITE-FILE.
DISPLAY "Enter record count, 50 - 1000".
ACCEPT REC-LIMIT.
OPEN OUTPUT IN-FILE.
COMPUTE HALF-WAY = REC-LIMIT / 2.
MOVE HALF-WAY TO COUNTER-1.
ADD HALF-WAY 1 GIVING COUNTER-2.
DISPLAY "Writing sort input, No. recs = ", REC-LIMIT.
ACCEPT TIMER-START FROM TIME.
PERFORM 120-WRITE-LOOP THRU 120-EXIT HALF-WAY TIMES.
CLOSE IN-FILE.
ACCEPT TIMER-END FROM TIME.
PERFORM 2400-CALC-TIME THRU 2400-EXIT.
DISPLAY ELAPSED-TIME.
100-EXIT. EXIT.
120-WRITE-LOOP.
MOVE "RECORD" TO SEQ-REC-WORD.
MOVE COUNTER-1 TO SEQ-REC-NUM.
MOVE SPACES TO SEQ-REC-TAIL.
WRITE RECORD-1.
MOVE "RECORD" TO SEQ-REC-WORD.
MOVE COUNTER-2 TO SEQ-REC-NUM.
MOVE SPACES TO SEQ-REC-TAIL.
WRITE RECORD-1.
SUBTRACT 1 FROM COUNTER-1.
ADD 1 TO COUNTER-2.
120-EXIT. EXIT.
200-SORT-FILE.
DISPLAY "Beginning Sort".
ACCEPT TIMER-START FROM TIME.
SORT SORT-WORK ON ASCENDING KEY SORT-REC-NUM
USING IN-FILE GIVING OUT-FILE.
ACCEPT TIMER-END FROM TIME.
PERFORM 2400-CALC-TIME THRU 2400-EXIT.
DISPLAY ELAPSED-TIME.
200-EXIT. EXIT.
COPY TIMERPRO.